layui.define(['element', 'jquery'], function(exports) {
    var $ = layui.jquery,
        element = layui.element;

	var hideBtn = $('#hideBtn');
	var mainLayout = $('#main-layout');
	var mainMask = $('.main-mask');
	//监听导航点击
	element.on('nav(leftNav)', function(elem) {
		var url = elem.attr('data-url');
		if(!url){
			return;
		}
        $('.iframe').attr('src',path+url);
	});

	//监听导航点击
	element.on('nav(rightNav)', function(elem) {
		var url = elem.attr('data-url');
		if(!url){
			return;
		}else if(url=='/api/doLogout'){
            window.location.href = path+url;
		}else {
            $('.iframe').attr('src',path+url);
        }
	});

	//菜单隐藏显示
	hideBtn.on('click', function() {
		if(!mainLayout.hasClass('hide-side')) {
			mainLayout.addClass('hide-side');
		} else {
			mainLayout.removeClass('hide-side');
		}
	});
	//遮罩点击隐藏
	mainMask.on('click', function() {
		mainLayout.removeClass('hide-side');
	});

    exports('main', {}); //注意，这里是模块输出的核心，模块名必须和use时的模块名一致
});